
const nodePath = require("path");
const nodeUrl = require("url");
const queryString = require("query-string");
const normalize = require("normalize-path");

function urlParse (url) {
    let parsed = nodeUrl.parse(url);
    let param = queryString.parse(parsed.query);
    let segment = normalize(parsed.pathname).split("/");
    if (segment[0] === "") {
        segment.splice(0, 1);
    }
    return {
        ...parsed,
        param: param,
        segment: segment
    }
}

module.exports = urlParse;